<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition   xmlns="http://www.w3.org/1999/xhtml"
			      xmlns:h="http://java.sun.com/jsf/html"
				  xmlns:p="http://primefaces.org/ui"
			      xmlns:f="http://java.sun.com/jsf/core"
			      xmlns:ui="http://java.sun.com/jsf/facelets"
			      > 
	
	
	 
	    <p:panel header="Search Options" toggleable="true" toggleOrientation="vertical" collapsed="false">  
   		<p:panelGrid columns="4" style="margin-bottom:10px;font-size:14px;" cellpadding="5">  
  		<f:facet name="header">  
        
    	</f:facet>  
            <h:outputText value="Region: " /> 
        <p:selectOneMenu style="width:170px" value="#{chubInvoicesManagedBean.region}" required="true"> 
        	<f:selectItem itemLabel="--Select Region--" itemValue="" />   
            <f:selectItems value="#{servicesManagedBean.regionList}" />  
            <p:ajax update="InvoicesCountries" listener="#{chubInvoicesManagedBean.updateCountries}" />
        </p:selectOneMenu>
        
 		<h:outputText value="Country: " /> 
        <p:selectOneMenu style="width:180px" id ="InvoicesCountries" value="#{chubInvoicesManagedBean.country}">
        	<f:selectItem itemLabel="--Select Country--" itemValue="" />    
            <f:selectItems value="#{chubInvoicesManagedBean.countriesList}" /> 
            <p:ajax update="CIDistributors" listener="#{chubInvoicesManagedBean.updateDistributorsList}"/>  
        </p:selectOneMenu>      
	         
	    <h:outputText value="Distributor: " />   
        <p:selectOneMenu value="#{chubInvoicesManagedBean.distributor}" id="CIDistributors">  
            <f:selectItems value="#{chubInvoicesManagedBean.distList}"  />  
        </p:selectOneMenu>  
        
        <h:outputText value="From: " />  
 		<p:calendar id="invfrom"  styleClass="calendarFilter" pattern="dd-MMM-yy" value="#{chubInvoicesManagedBean.from}" showOn="button" required="true" requiredMessage="Required">
        </p:calendar>
        
        <h:outputText value="To: " />
        <p:calendar id="invto"  styleClass="calendarFilter" pattern="dd-MMM-yy" value="#{chubInvoicesManagedBean.to}" showOn="button" required="true" requiredMessage="Required">
        </p:calendar>
         
         <p:column colspan="7">  
        <p:commandButton value="GO" update="ChubInvoicesdataTable @form" action="#{chubInvoicesManagedBean.callChubInvoicesProcedure}" global="true" />
        </p:column> 
        
         <h:commandLink rendered="#{chubInvoicesManagedBean.procedureCalled}">  
        <p:graphicImage value="NWDSAKMS-excel-logo.png" width="30" height="30" title="Export to Excel"  style="border:0;margin-left:5px"/>  
        <p:dataExporter type="xls" target="InvoicesdataTable" fileName="Chub_Invoices_#{servicesManagedBean.dateNow}" />  
    	</h:commandLink>    
    </p:panelGrid>
    
    </p:panel>    
    
<p:panel id="ChubInvoicesdataTable"> 
<p:dataTable  id="InvoicesdataTable"
			  rendered="#{chubInvoicesManagedBean.procedureCalled}"
			  style="margin-top:5px" 
			  var="inv" value="#{chubInvoicesManagedBean.iList}"  
              paginator="true" 
              rows="30"   
              paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
              rowsPerPageTemplate="20,40,60,80" 
              lazy="true"    
              scrollRows="17" 
              >  
        <f:facet name="header">  
            Chub Invoices  
        </f:facet> 
        <p:column >  
            <f:facet name="header">  
                    Distributor
            </f:facet>  
            <h:outputText value="#{inv.distributorNo}"/>  
        </p:column>  
  
        <p:column >  
            <f:facet name="header" >  
                    Country 
            </f:facet>  
            <h:outputText value="#{inv.country}"/>
        </p:column>  
        
        <p:column>
        <f:facet name="header">  
                    Invoice Date 
            </f:facet>  
            <h:outputText value="#{inv.invoiceDate}"/> 
        </p:column>  
        
        
        <p:column>
        <f:facet name="header">  
                   Uni Material
            </f:facet>  
            <h:outputText value="#{inv.uniMaterial}"/> 
        </p:column>
        
         <p:column>
        <f:facet name="header">  
                   UOM
            </f:facet>  
            <h:outputText value="#{inv.uom}"/> 
        </p:column>
        
         <p:column>
        <f:facet name="header">  
                   Net GSV
            </f:facet>  
            <h:outputText value="#{inv.netGsv}"/> 
        </p:column>
        
         <p:column>
        <f:facet name="header">  
                   Net QTY
            </f:facet>  
            <h:outputText value="#{inv.netQty}"/> 
        </p:column>
   
    </p:dataTable> 
     </p:panel>
   
</ui:composition>